Show:

Q tabs Class

This tool renders a nice set of tabs that adapts to different environments

Constructor

Q tabs

(
  • [options]
)
Q.Tool

Parameters:

  • [options] Object optional

    This object contains properties for this function

    • [tabs] Array optional

      An associative array of name: title pairs.

    • [urls] Array optional

      An associative array of name: url pairs to override the default urls.

    • [field='tab'] String optional

      Uses this field when urls doesn't contain the tab name.

    • [checkQueryString=false] Boolean optional

      Whether the default getCurrentTab should check the querystring when determining the current tab

    • [vertical=false] Boolean optional

      Stack the tabs vertically instead of horizontally

    • [compact=false] Boolean optional

      Display the tabs interface in a compact space with a contextual menu

    • [overflow] Object optional
      • [content] String optional
        The html that is displayed when the tabs overflow. You can interpolate {{count}}, {{text}} or {{html}} in the string.
      • [glyph] String optional
        Override the glyph that appears next to the overflow text. You can interpolate {{count}} here
      • [defaultText] String optional
        The text to interpolate {{text}} in the content when no tab is selected
      • [defaultHtml] String optional
        The text to interpolate {{text}} in the content when no tab is selected
    • [selectors] String optional

      Object of {slotName: selector} pairs, where the values are CSS style selectors indicating the element to update with javascript, and can be a parent of the tabs. Set to null to reload the page.

    • [slot] String optional

      The name of the slot to request when changing tabs with javascript.

    • [loader] Function optional

      Name of a function which takes url, slot, callback. It should call the callback and pass it an object with the response info. Can be used to implement caching, etc. instead of the default HTTP request. This function shall be Q.batcher getter

    • [onClick] Q.Event optional

      Event when a tab was clicked, with arguments (name, element). Returning false cancels the tab switching.

    • [beforeSwitch] Q.Event optional

      Event when tab switching begins. Returning false cancels the switching.

    • [beforeScripts] Function optional

      Name of the function to execute after tab is loaded but before its javascript is executed.

    • [onCurrent] Function optional

      Event after a tab has been selected. Note that this is in the view layer, so your handlers would trigger recursion if they call Q.layout().

    • [onActivate] Function optional

      Event after a tab has been activated. Note that this is in the view layer, so your handlers would trigger recursion if they call Q.layout().

    • [beforeRefresh] Function optional

      Event before tabs are going to be refreshed

    • [onRefresh] Function optional

      Event after tabs have been refreshed

Returns:

Methods

getCurrentTab

(
  • [tab]
)
Element

Called by indicateCurrent. You can override this function to provide your own mechanisms for indicating the current tab and returning it.

Parameters:

  • [tab] String optional

    a possible tab the caller requested to indicate as current

Returns:

Element:

The current tab element.

getName

(
  • tab
)
String

Parameters:

Returns:

String:

the name of the tab

getUrl

(
  • tab
)
String

Parameters:

Returns:

String:

the url that the tab links to

indicateCurrent

(
  • [tab]
)

Parameters:

  • [tab] String optional

    a possible tab the caller requested to indicate as current

isInDialog

() Boolean

Returns:

Boolean:

whether the tabs are rendered inside an overlay / dialog

refresh

()

Render the tabs element again and indicate the selected tab

switchTo

(
  • name
  • loaderOptions
  • extra
)

Parameters:

  • name String | Array

    the name of the tab to switch to. Can also be [name, tabElement]

  • loaderOptions Object

    any options to merge on top of tool.state.loaderOptions

  • extra Mixed

    anything to pass to beforeSwitch handlers